package io.sunny.platform.mcp.application.service.impl;

import io.sunny.platform.mcp.application.service.BookService;
import io.sunny.platform.mcp.domain.model.Book;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.function.Function;

/**
 * @Author SUNNY
 * @Date 2025/11/8 20:58
 * @PackageName: io.sunny.platform.mcp.service
 * @Description: 图书查询服务，将查询方法作为函数BEAN导出
 * @Version 1.0
 */
@Service
public class BookQueryService {
    @Resource
    private BookService bookService;

    /**
     * 根据作者查询图书的函数BEAN
     */
    @Bean
    public Function<String, List<Book>> findBooksByAuthor() {
        return author -> bookService.findBooksByAuthor(author);
    }

    /**
     * 根据分类查询图书的函数BEAN
     */
    @Bean
    public Function<String, List<Book>> findBooksByCategory() {
        return category -> bookService.findBooksByCategory(category);
    }
}
